	<h2>Edit User Authen (<?php echo $userData->UserID?>) <?php echo $userData->SALES_NAME?></h2>
	<form id="myForm" action="<?php echo $current?>updateAuthen" class="form-horizontal" role="form">
	<?
			
	?>
	
	<?
	foreach($role as $in=>$val):
	?>
		<div class="boxRole">
			<h2><?php echo $val->RoleName?></h2>
			<ul class="sectionSelect">
			<?
			$i=0;
			foreach($authen as $j=>$k){
				$checked = ($i==0) ? 'style="display:block;width:100%"':"";
			?>
				<li <?php echo $checked ?>>
					<label><input type="checkbox" name="autheid[]" value="<?php echo $val->ID?>,<?php echo $k->ID?>,<?php echo $val->Controller?>-<?php echo $k->AuthenUniqueName?>" />
					<?php echo $k->AuthenName?>
					</label>
				</li>
			<?
				$i++;
			}
			?>
			</ul>
		</div>
	<?	
	endforeach;
	echo $genhtml -> getButton("submit", "UpdateAuthen", "Update", "info");
	?>
	
	<br />
	<input type="hidden" name="userID" value="<?php echo $userID?>" />
	<!-- JavaScript jQuery code from Bootply.com editor  -->
	<script type="text/javascript">
		var dataSelect  = <?php echo json_encode($myAuthen)?>;
		$(function(){
			
			
		
			$.each(dataSelect,function(a,b){
				
				value = b.AuthenID+","+b.RoleID+","+b.AuthenRoleName;
				
				$('input[value="'+value+'"]').prop("checked",true);
			})
		})
	</script>
	<script type='text/javascript'>
		$(function() {
			initNormalForm(function(data) {
				window.location.reload();
			})
			$('.sectionSelect input').click(function(){
				index = $(this).parents('li').index();
				var obj = $(this).parents('.sectionSelect')
				if(index==0){
					obj.find('input:gt(0)').prop("checked",false);
					
				}else{
					obj.find('input:eq(0)').prop("checked",false);
					var sizeNotChecked = obj.find('input:gt(0)').not(":checked").size();
					
					if(sizeNotChecked ==0){
						
						obj.find('input:gt(0)').prop("checked",false);
						obj.find('input:eq(0)').prop("checked",true);
						/*
						//obj.find('input').attr("checked","checkted");
						
						obj.find('input:gt(0)').prop("checked");
						
						console.log("reset");*/
					}
				}
			})
		})
	</script>

</form>